home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 4
/
Amiga Tools 4.iso
/
tools
/
mail-tools
/
thor
/
thor_2.22
/
thor.lha
/
rexx
/
UUEncode.thor
< prev
next >
Wrap
Text File
|
1995-12-18
|
5KB
|
197 lines
/* UUEncode.thor by Troels Walsted Hansen
** $VER: UUEncode.thor v2.00 (01.11.94)
**
** An ARexx script that uuencodes a file and either places it in the
** clipboard or posts a message for you containing the file. Using
** LhA, this script will archive the file if it isn't already.
**
** Utilises LhA by Stefan Boberg for archiving.
** The script may use either of the following for uuencoding:
** · UUFast v1.25 by Jørn Halonen
** · uuIn v1.03 by Nicolas Dade
** · UUxT v3.0 by Asher Feldman
**
** New: · This version is only for THOR v2.0 or higher.
** · A lot easier to adapt to other uuencoders and includes
** commandstrings for uuIn, UUFast and UUxT.
** · Doesn't require rexxsupport.library anymore.
** · Doesn't require MagicClip anymore.
*/
/* some user variables. edit to your hearts content */
tmpdir = "T:" /* Work dir for the encoding */
uuencoder = "uuin" /* may be: uuin, uufast or uuxt */
/* needs THOR and bbsread.library functions */
options results
p = address() || ' ' || show('P',,)
thorport = pos('THOR.',p)
if thorport > 0 then thorport = word(substr(p,thorport),1)
else
do
say 'No THOR port found!'
exit 10
end
if ~show('p', 'BBSREAD') then
do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
/* get filename */
address(bbsread)
GETGLOBALDATA STEM GLOBALDATA
address(thorport)
THORTOFRONT
REQUESTFILE TITLE '"Select file to encode:"' ID '"'GLOBALDATA.UPLOADPATH'"' FP PAT '"#?"'
if(rc ~= 0) then exit
filetoencode = result
lastchar = right(filetoencode,1)
if(lastchar = "/" | lastchar = ":" | filetoencode = "") then
do
REQUESTNOTIFY TEXT '"No file selected!"' BT '"_Ok"'
call CleanUp()
end
posi = lastpos("/",FileToEncode)
if(posi = 0) then posi = lastpos(":",FileToEncode)
WithoutPath = substr(FileToEncode,posi+1)
/* if file isn't LhA'ed -- do it ourselves */
extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
if~(extension = "LHA" | extension = "LZH") then
do
REQUESTNOTIFY TEXT '"Do you want to LhA the file?"' BT '"_Yes|_No"'
if(result) then
do
address command "LhA >nil: -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
if(rc ~= 0) then REQUESTNOTIFY TEXT '"LhA''ing did not succeed."' BT '"_Ok"'
else FileToEncode = tmpdir||WithoutPath||".lha"
end
end
/* select correct uuencoder commandstring */
select
when(uuencoder = 'uufast') then cmd = "UUFast >nil: " || '"' || filetoencode || '"' || " TO " || tmpdir || "Message.uu E"
when(uuencoder = 'uuin') then cmd = "uuIn >nil: INFILE=" || '"' || filetoencode || '"' || " OUTFILE=" || tmpdir || "Message.uu"
when(uuencoder = 'uuxt') then cmd = 'UUxT >nil: a ' || tmpdir || 'Message.uu ' || '"'filetoencode'"'
otherwise
do
REQUESTNOTIFY TEXT '"UUEncoder not configured correctly."' BT '"_Ok"'
call CleanUp()
end
end
address command cmd
if ~exists(tmpdir"Message.uu") then
do
REQUESTNOTIFY TEXT '"Something went wrong during uuencoding."' BT '"_Ok"'
call CleanUp()
end
REQUESTNOTIFY TEXT '"Place in clipboard or post as a message?"' BT '"Clip_board|_Post|_Cancel"'
choice = result
if(choice = 1) then
do
PUTCLIP unit 0 file '"'tmpdir'Message.uu"'
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'THOR.LASTERROR'"' BT '"_Ok"'
exit 5
end
end
else if(choice = 2) then
do
drop EVENT.
address(bbsread)
GETBBSLIST stem BBSLIST
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit 5
end
address(thorport)
REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
if(rc ~= 0) then break
else bbs = result
address(bbsread)
GETCONFLIST '"'bbs'"' CONFLIST
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit 5
end
address(thorport)
REQUESTLIST instem CONFLIST title '"Select conf:"' SIZEGADGET
if(rc ~= 0) then break
else EVENT.CONFERENCE = result
REQUESTSTRING TITLE '"Please enter subject of message:"' BT '"_Ok|_Cancel"' ID '"'WithoutPath'"' MAXCHARS 100
EVENT.SUBJECT = result
if(rc ~= 0 | EVENT.SUBJECT = "") then break
REQUESTSTRING TITLE '"Please enter receiver name:"' BT '"_Ok|_Cancel"' ID '"ALL"' MAXCHARS 100
EVENT.TONAME = result
if(rc ~= 0 | EVENT.TONAME = "") then break
address(bbsread)
UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit
end
address command 'copy >nil: ' || tmpdir || 'Message.uu TO ' || UNIQUEFILE.NAME
EVENT.MSGFILE = UNIQUEFILE.FILEPART
WRITEBREVENT bbsname '"'bbs'"' event 0 stem EVENT
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit 5
end
else
do
address(thorport)
PACKEVENTS '"'bbs'"'
RESCAN
end
end
call CleanUp()
/* cleanup and exit */
CleanUp:
if(exists(tmpdir || WithoutPath || ".lha")) then address command 'delete >nil: ' || '"' || tmpdir || WithoutPath || '.lha' || '"'
if(exists(tmpdir || "Message.uu")) then address command 'delete >nil: ' || tmpdir || 'Message.uu'
exit
return